#!/bin/bash
set -e
#原仓库路径(后续要重命名为新仓路径)
old_repo_url=$1
#临时参考路径（后续要重命名为原仓路径）
temp_repo_url=$2
#git账号
username=$3
#git密码
password=$4
old_repo_name=${old_repo_url##*/}

cur_pwd=$(cd $(dirname $0);pwd)
cd $cur_pwd
#带账号信息的url
old_repo_url_full=${old_repo_url#https:\/\/*}
temp_repo_url_full=${temp_repo_url#https:\/\/*}
old_repo_url_full="https://$username:$password@$old_repo_url_full"
temp_repo_url_full="https://$username:$password@$temp_repo_url_full"
#echo $old_repo_url_full
#echo $temp_repo_url_full
rm -rf $old_repo_name.git
git clone $old_repo_url_full --bare $old_repo_name.git
cd $old_repo_name.git
git push --mirror $temp_repo_url_full
cd $cur_pwd
rm -rf $old_repo_name.git
